package com.free.solon.controller;

import com.free.solon.common.model.PageResult;
import com.free.solon.common.model.R;
import com.free.solon.model.CropCategory;
import com.free.solon.service.CropCategoryService;
import org.noear.solon.annotation.Controller;
import org.noear.solon.annotation.Get;
import org.noear.solon.annotation.Inject;
import org.noear.solon.annotation.Mapping;
import org.noear.solon.validation.annotation.*;

/**
 * 示例 RestFul api
 *
 * @Author: hao.ding@insentek.com
 * @Date: 2024/5/21 9:51
 */
@Valid
@Controller
@Mapping("category")
public class CropCategoryController {

    @Inject
    CropCategoryService cropCategoryService;

    @Get
    @Mapping("/pages")
    public PageResult<CropCategory> getPages(Integer page, Integer limit) {
        return cropCategoryService.getPages(page, limit);
    }

    @Get
    @Mapping("/info")
    public R<CropCategory> getCategory(Long id) {
        CropCategory cropCategory = cropCategoryService.getById(id);
        return R.succeed(cropCategory);
    }

}
